<form action="index.php?r=rbac/perupdate" method="post">
<div >
	<?php echo "<center><h4>".$roleName."角色权限<h4></center>";?>
		<ul>
		<?php 
		//构造数组将角色权限写到数组中
		$temp=[];
		foreach ($rolepermission as $r){
			$temp[]=$r->child;
		}
		echo "<h4>网站设置模块</h4>";
		foreach ($setPermission as $s){	
			//判断模块中的权限是否是角色的权限，如果是复选框被选中
			if(in_array($s['name'],$temp)){
				echo "<li style=\"float:left;margin-left:15px;list-style-type:none;\"><input type=\"checkbox\" name=\"set[]\" value=\"".$s['name']."\" checked=\"checked\" />".$s['description']."</li>";
			}else{
				echo "<li style=\"float:left;margin-left:15px;list-style-type:none;\"><input type=\"checkbox\" name=\"set[]\" value=\"".$s['name']."\" />".$s['description']."</li>";
			}	
		}
		
		?>
		</ul>
	
		<ul>
		<?php 
		echo "<br />";
		echo "<h4>账号管理模块</h4>";
		foreach ($accountPermission as $a){
			if(in_array($a['name'], $temp)){
				echo "<li style=\"float:left;margin-left:15px;list-style-type:none;\"><input type=\"checkbox\" name=\"account[]\" value=\"".$a['name']."\" checked=\"checked\" />".$a['description']."</li>";
			}else{
				echo "<li style=\"float:left;margin-left:15px;list-style-type:none;\"><input type=\"checkbox\" name=\"account[]\" value=\"".$a['name']."\" />".$a['description']."</li>";
			}
			
		}
		?>
		<br />
		<?php 
		echo "<br />";
		echo "<h4>会员管理模块</h4>";
		foreach ($memberPermission as $m){
			if(in_array($m['name'], $temp)){
				echo "<li style=\"float:left;margin-left:15px;list-style-type:none;\"><input type=\"checkbox\" name=\"member[]\" value=\"".$m['name']."\" checked=\"checked\" />".$m['description']."</li>";
			}else{
				echo "<li style=\"float:left;margin-left:15px;list-style-type:none;\"><input type=\"checkbox\" name=\"member[]\" value=\"".$m['name']."\" />".$m['description']."</li>";
			}		
		}
		?>
		</ul>
		<br />
		<ul>
		<?php 
		echo "<br /><h4>商品管理模块</h4>";
		foreach ($productPermission as $p){
			if(in_array($p['name'], $temp)){
				echo "<li style=\"float:left;margin-left:15px;list-style-type:none;\"><input type=\"checkbox\" name=\"product[]\" value=\"".$p['name']."\" checked=\"checked\" />".$p['description']."</li>";
			}else{
				echo "<li style=\"float:left;margin-left:15px;list-style-type:none;\"><input type=\"checkbox\" name=\"product[]\" value=\"".$p['name']."\" />".$p['description']."</li>";
			}
			
		}
		echo "<br />";
		?>
		</ul>
	<br />
	<ul>
	<?php 
	echo "<br /><h4>订单管理模块</h4>";
	foreach ($orderPermission as $o){
		if(in_array($o['name'], $temp)){
			echo "<li style=\"float:left;margin-left:15px;list-style-type:none;\"><input type=\"checkbox\" name=\"order[]\" value=\"".$o['name']."\" checked=\"checked\" />".$o['description']."</li>";
		}else{
			echo "<li style=\"float:left;margin-left:15px;list-style-type:none;\"><input type=\"checkbox\" name=\"order[]\" value=\"".$o['name']."\" />".$o['description']."</li>";
		}
		
	}
	?>
	</ul>

	<ul>
	<?php 
	echo "<br /><h4>系统权限</h4>";
	foreach ($sysPermission as $s){
		if(in_array($s['name'], $temp)){
			echo "<li style=\"float:left;margin-left:15px;list-style-type:none;\"><input type=\"checkbox\" name=\"system[]\" value=\"".$s['name']."\"  checked=\"checked\" />".$s['description']."</li>";
		}else{
			echo "<li style=\"float:left;margin-left:15px;list-style-type:none;\"><input type=\"checkbox\" name=\"system[]\" value=\"".$s['name']."\" />".$s['description']."</li>";
		}
		
	}
	echo "<br />";
	?>
	</ul>
	<br />
	<ul>
	<?php 
	echo "<br /><h4>统计报表模块</h4>";
	foreach ($reportPermission as $r){
		if(in_array($r['name'], $temp)){
			echo "<li style=\"float:left;margin-left:15px;list-style-type:none;\"><input type=\"checkbox\" name=\"report[]\" value=\"".$r['name']."\"   checked=\"checked\" />".$r['description']."</li>";
		}else{
			echo "<li style=\"float:left;margin-left:15px;list-style-type:none;\"><input type=\"checkbox\" name=\"report[]\" value=\"".$r['name']."\" />".$r['description']."</li>";
		}
		
	}
	echo "<input type=\"hidden\" name=\"rolename\" value=\"".$roleName."\">";
	?>
	</ul>
	<br />
	<div class="clearfix form-actions">
		<div class="col-md-offset-3 col-md-9">
			<button class="btn btn-info" type="submit">
				<i class="ace-icon fa fa-check bigger-110"></i>
				提交
			</button>
	
			&nbsp; &nbsp; &nbsp;
			<button class="btn" type="reset">
				<i class="ace-icon fa fa-undo bigger-110"></i>
				重置
			</button>
		</div>
	</div>
</div>
</form>